<template>
  <div class="page memberPay flex flex-direction">
    <div class="payBg"></div>
    <div
      class="flex align-center flex-direction"
      style="flex: 1;"
    >
      <div class="payBox">
        <div class="payBoxTit">支付金额</div>
        <div class="flex justify-sb align-center payNumBox">
          <div class="payIcon">¥</div>
          <div class="payNum flex">
            <div>{{ numInput }}</div>
            <div class="payInputLine"></div>
          </div>
        </div>
        <div class="flex justify-sb align-center payLink">
          <div @click="isRemarkShow=true">添加备注</div>
          <div></div>
        </div>
      </div>
      <div class="memberVal">会员余额: ¥ 1000</div>
      <div class="payTrademark">家有福利社提供技术支持</div>
    </div>
    <NumberKey
      :is-meber-pay="true"
      @getPay="onGetMoneyNum"
      @pay="onPay"
      @payMember="onPayMember"
    />
    <van-popup
      v-model:show="swipeIndex"
      round
      position="bottom"
    >
      <div class="flex justify-sb align-center modelTop">
        <div class="modelArr" @click="onBack()">
          <van-icon v-show="swipeIndex == 1" name="cross" />
          <van-icon v-show="swipeIndex != 1" name="arrow-left" />
        </div>
        <div>请确认订单</div>
        <div class="modelEmtry"></div>
      </div>
      <div class="modelCont">
        <div v-show="swipeIndex == 1">
          <div class="modelMemberBox">
            <div class="mMName">会员商户</div>
            <div class="mMNamePrice">¥ <span>{{ numInput }}</span></div>
            <div class="mMOrder">
              <div class="flex justify-sb align-center">
                <div>订单金额</div>
                <div>¥{{ numInput }}</div>
              </div>
              <div class="flex justify-sb align-center mMOrderAct">
                <div>活动优惠</div>
                <div>- ¥0.00</div>
              </div>
              <div class="flex justify-sb align-center mMOrderJ" @click="swipeIndex = 3">
                <div>选择优惠券</div>
                <div class="flex align-center">
                  <div style="line-height:1rem;">无</div>
                  <div class="flex align-center" style="color:#bbb;margin-top:1px;"><van-icon name="arrow" /></div>
                </div>
              </div>
            </div>
          </div>
          <van-cell is-link @click="swipeIndex = 2">
            <template #title>
              <div class="flex">
                <img src="@/assets/memberPay/vipOne.png" alt="" class="modelMemberIcon" />
                <div class="modelMemberTit">会员支付</div>
              </div>
            </template>
          </van-cell>

          <van-cell>
            <template #title>
              <div class="flex justify-sb">
                <div class="flex">
                  <img src="@/assets/memberPay/vipThree.png" alt="" class="modelMemberIcon" />
                  <div class="modelMemberTit">会员卡余额: <span class="modelMemberPrice">¥1000</span></div>
                </div>
                <div style="color: #1E8DFF;" @click="onGoPage('recharge')">充值</div>
              </div>
            </template>
          </van-cell>
          <div class="mMButton" @click="onMemberPay">确认支付</div>
        </div>
        <div v-show="swipeIndex == 2">
          <van-cell is-link @click="swipeIndex = 1">
            <template #title>
              <div class="flex">
                <img src="@/assets/memberPay/vipOne.png" alt="" class="modelMemberIcon" />
                <div class="modelMemberTit">会员支付</div>
                <div class="modelMemberTag">推荐</div>
              </div>
            </template>
          </van-cell>
          <van-cell is-link @click="onWxPay()">
            <template #title>
              <div class="flex">
                <img v-if="env=='Wx'" src="@/assets/memberPay/vipTwo.png" alt="" class="modelMemberIcon" />
                <img v-else src="@/assets/memberPay/zhifubao.png" alt="" class="modelMemberIcon" />
                <div class="modelMemberTit">{{ envTitle }}</div>
              </div>
            </template>
          </van-cell>
        </div>
        <div v-show="swipeIndex == 3">
          <van-cell is-link @click="onSelCoupon">
            <template #title>
              <div class="flex">
                <div class="modelMemberTit">满20减10元</div>
                <div class="modelMemberTag">推荐</div>
              </div>
            </template>
          </van-cell>
        </div>
      </div>
    </van-popup>
    <!-- 备注 -->
    <van-popup
      v-model:show="isRemarkShow"
      round
      closeable
      position="bottom"
    >
      <div class="remarkBox">
        <div class="remarkTit">订单备注</div>
        <van-field
          v-model="remark.new"
          rows="3"
          autosize
          type="textarea"
          maxlength="30"
          placeholder="请输入备注内容"
          show-word-limit
          class="remarkText"
        />
        <div class="remarkBut" @click="onGetRemark()">确定</div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import NumberKey from '@/components/NumberKey.vue'
// import { commonAjax } from 'Ajax'
// import { tuneUpZFB, tuneUpWX } from '@/utils/utils'
// import { getCookie } from '@/utils/validate.js'
export default {
  components: {
    NumberKey
  },
  data() {
    return {
      payEnv: this.$store.getters.env,
      numInput: '',
      payStatus: 0, // 0 未支付 1 正在支付中
      isRemarkShow: false,
      remark: {
        new: '',
        use: ''
      },
      model: true,
      swipeIndex: 0
    }
  },
  computed: {
    envTitle: function() {
      if (this.payEnv === 'WX') {
        return '微信支付'
      } else if (this.payEnv === 'ZFB') {
        return '支付宝支付'
      } else {
        return '其他支付'
      }
    }
  },
  methods: {
    onGetRemark() {
      this.remark.new ? this.remark.use = this.remark.new : this.$toast('请输入备注~')
      this.isRemarkShow = false
    },
    onGetMoneyNum(num) { this.numInput = num },
    onBack() {
      if (this.swipeIndex) {
        this.swipeIndex = this.swipeIndex - 1
      }
    },
    onPay() {
      this.swipeIndex = 1
    },
    onPayMember() {
    },
    onSelCoupon() {
      this.swipeIndex = 1
    },
    // 会员支付
    onMemberPay() {
      this.$jump({ path: '/pay-success', query: { type: 1 }})
    },
    // 微信支付
    onWxPay() {
      this.$jump({ path: '/pay-success', query: { type: 0 }})
    },
    onGoPage(url) {
      url = '/' + url
      this.$jump(url)
    }
  }
}
</script>

<style scoped>
.memberPay{
  background: #F2F2F2;
}
.payBg{
  width: 750px;
  height: 300px;
  background: url('../../assets/memberPay/bg.png') no-repeat;
  background-size: 100% 100%;
}
.payBox{
  width: 596px;
  height: 300px;
  padding: 38px 30px 36px 34px;
  background: #FFFFFF;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-top: -78px;
}
.payBoxTit{
  font-size: 28px;
  color: #000;
}
.payNumBox{
  padding: 32px 0;
  border-bottom: 1px solid #F7F7F7;
}
.payIcon{
  font-size: 70px;
  font-weight: 700;
}
.payNum{
  text-align: right;
  height: 52px;
  font-size: 70px;
  font-family: DIN Alternate;
  font-weight: bold;
  color: #000000;
  line-height: 70px;
}
.payInputLine{
  width: 5px;
  height: 70px;
  background: #CA0114;
}
.payLink{
  font-size: 26px;
  color: #1D97FF;
}
.memberVal{
  width: 660px;
  font-size: 26px;
  margin-top: 30px;
}
.payTrademark{
  font-size: 24px;
  font-weight: 400;
  color: #ABABAB;
  padding-top: 30px;
  text-align: center;
  flex: 1;
}
.modelTop{
  height: 100px;
  background: #F3F3F3;
  font-size: 36px;
  color: #000000;
}
.modelArr{
  width: 100px;
  height: 100px;
  line-height: 100px;
  text-align: center;
  font-size: 36px;
  color: #bbb;
}
.modelEmtry{
  width: 100px;
  height: 100%;
}
.modelMemberIcon{
  width: 40px;
  height: 40px;
  display: block;
}
.modelMemberTit{
  font-size: 28px;
  color: #000000;
  margin: 0 26px 0 37px;
}
.modelCont{
  min-height: 286px;
}
.modelMemberTag{
  background: #FD8013;
  border-radius: 6px;
  color: #fff;
  padding: 2px 4px;
  line-height: 1rem;
  font-size: 16px;
  height: 1rem;
  margin: auto 0;
}
.modelMemberBox{
}
.modelMemberPrice{
  color: #000000;
  font-size: 30px;
  font-weight: 600;
}
.mMName{
  text-align: center;
  color: #3F3F3F;
  font-size: 28px;
  padding: 58px 0 30px;
}
.mMNamePrice{
  font-size: 50px;
  color: #000000;
  text-align: center;
  font-weight: 600;
  padding-bottom: 82px;
}
.mMButton{
  width: 630px;
  height: 100px;
  line-height: 100px;
  background: linear-gradient(90deg, #EF3814 0%, #FF8D13 100%);
  box-shadow: 0px 6px 11px 1px #FFC9AB;
  border-radius: 20px;
  margin: 68px auto 40px;
  font-size: 34px;
  color: #FFFFFF;
  text-align: center;
}
.mMOrder{
  padding: 0 36px 38px;
  font-size: 28px;
  color: #4C4C4C;
}
.mMOrderAct{
  margin: 28px 0 10px;
  color: #FD8013;
}
.mMOrderJ{
  color: #FD8013;
  padding-bottom: 38px;
  border-bottom: 1px solid #E8E8E8;
}

/* 备注 */
.remarkBox{
  width: 100%;
  height: 556px;
}
.remarkTit{
  width: 100%;
  height: 126px;
  text-align: center;
  font-size: 26px;
  font-weight: 600;
  color: #000000;
  line-height: 126px;
}
.remarkBox >>> .remarkText{
  margin: 0 auto;
  width: 650px;
  background: #F7F7F7;
  border-radius: 4px;
  padding: 20px;
}
.remarkBox >>> .van-field__word-limit{
  font-size: 24px;
  font-weight: 600;
  color: #BBBBBB;
}
.remarkBut{
  width: 630px;
  height: 80px;
  background: linear-gradient(90deg, #EF3814 0%, #FF8D13 100%);
  border-radius: 10px;
  margin: 66px auto 0;
  font-size: 28px;
  font-weight: 600;
  color: #FFFFFF;
  line-height: 80px;
  text-align: center;
}
</style>
